﻿<Window x:Class="Meridian.Views.MiniView"
        xmlns="http://schemas.microsoft.com/winfx/2006/xaml/presentation"
        xmlns:x="http://schemas.microsoft.com/winfx/2006/xaml" xmlns:Properties="clr-namespace:Meridian.Properties"
        Title="{Binding Title}" Height="265" Width="185"
        WindowStyle="None" ResizeMode="CanMinimize" AllowsTransparency="True" Background="Transparent" Topmost="{Binding ElementName=TopMostItem, Path=IsChecked}"
        MouseMove="WindowMouseMove">
    <Window.TaskbarItemInfo>
        <TaskbarItemInfo x:Name="Taskbar">
            <TaskbarItemInfo.ThumbButtonInfos>
                <ThumbButtonInfo x:Name="ThumbShuffleButton" IsEnabled="{Binding IsLoaded}" ImageSource="/Meridian;component/Resources/Images/shuffle_disabled_icon_thumb.png" Click="ThumbShuffleButtonClick"/>
                <ThumbButtonInfo x:Name="ThumbPrevButton" IsEnabled="{Binding IsLoaded}" ImageSource="/Meridian;component/Resources/Images/prev_thumb.png" Click="ThumbPrevButtonClick"/>
                <ThumbButtonInfo x:Name="ThumbPlayButton" IsEnabled="{Binding IsLoaded}" ImageSource="/Meridian;component/Resources/Images/play_thumb.png" Click="ThumbPlayButtonClick"/>
                <ThumbButtonInfo x:Name="ThumbNextButton" IsEnabled="{Binding IsLoaded}" ImageSource="/Meridian;component/Resources/Images/next_thumb.png" Click="ThumbNextButtonClick"/>
            </TaskbarItemInfo.ThumbButtonInfos>
        </TaskbarItemInfo>
    </Window.TaskbarItemInfo>
    <Window.ContextMenu>
        <ContextMenu>
            <MenuItem x:Name="TopMostItem" Header="{x:Static Properties:Resources.MiniTopMost}" IsCheckable="True"/>
        </ContextMenu>
    </Window.ContextMenu>
    <Window.Triggers>
        <EventTrigger RoutedEvent="Window.Loaded">
            <BeginStoryboard>
                <Storyboard>
                    <Storyboard>
                        <DoubleAnimationUsingKeyFrames Storyboard.TargetName="PlayPauseButton" Storyboard.TargetProperty="Opacity" DecelerationRatio="0.3">
                            <LinearDoubleKeyFrame KeyTime="0" Value="0"/>
                            <LinearDoubleKeyFrame KeyTime="0:0:0.1" Value="0"/>
                            <LinearDoubleKeyFrame KeyTime="0:0:0.2" Value="1"/>
                        </DoubleAnimationUsingKeyFrames>
                        <DoubleAnimationUsingKeyFrames Storyboard.TargetName="PlayPauseButton" Storyboard.TargetProperty="(RenderTransform).Y" AccelerationRatio="0.5" DecelerationRatio="0.3">
                            <LinearDoubleKeyFrame KeyTime="0" Value="10"/>
                            <LinearDoubleKeyFrame KeyTime="0:0:0.2" Value="-2"/>
                            <LinearDoubleKeyFrame KeyTime="0:0:0.3" Value="0"/>
                        </DoubleAnimationUsingKeyFrames>
                    </Storyboard>
                    <Storyboard>
                        <DoubleAnimationUsingKeyFrames Storyboard.TargetName="PrevButton" Storyboard.TargetProperty="Opacity" DecelerationRatio="0.3">
                            <LinearDoubleKeyFrame KeyTime="0:0:0.0" Value="0"/>
                            <LinearDoubleKeyFrame KeyTime="0:0:0.2" Value="0"/>
                            <LinearDoubleKeyFrame KeyTime="0:0:0.5" Value="1"/>
                        </DoubleAnimationUsingKeyFrames>
                        <DoubleAnimationUsingKeyFrames Storyboard.TargetName="PrevButton" Storyboard.TargetProperty="(RenderTransform).Y" DecelerationRatio="0.3">
                            <LinearDoubleKeyFrame KeyTime="0:0:0.2" Value="10"/>
                            <LinearDoubleKeyFrame KeyTime="0:0:0.4" Value="-2"/>
                            <LinearDoubleKeyFrame KeyTime="0:0:0.5" Value="0"/>
                        </DoubleAnimationUsingKeyFrames>
                    </Storyboard>
                    <Storyboard>
                        <DoubleAnimationUsingKeyFrames Storyboard.TargetName="NextButton" Storyboard.TargetProperty="Opacity" DecelerationRatio="0.3">
                            <LinearDoubleKeyFrame KeyTime="0:0:0.0" Value="0"/>
                            <LinearDoubleKeyFrame KeyTime="0:0:0.3" Value="0"/>
                            <LinearDoubleKeyFrame KeyTime="0:0:0.6" Value="1"/>
                        </DoubleAnimationUsingKeyFrames>
                        <DoubleAnimationUsingKeyFrames Storyboard.TargetName="NextButton" Storyboard.TargetProperty="(RenderTransform).Y" DecelerationRatio="0.3">
                            <LinearDoubleKeyFrame KeyTime="0:0:0.3" Value="10"/>
                            <LinearDoubleKeyFrame KeyTime="0:0:0.5" Value="-3"/>
                            <LinearDoubleKeyFrame KeyTime="0:0:0.6" Value="0"/>
                        </DoubleAnimationUsingKeyFrames>
                    </Storyboard>
                </Storyboard>
            </BeginStoryboard>
        </EventTrigger>
    </Window.Triggers>
    <Grid Name="RootGrid" Margin="15">
        <Rectangle Fill="Black" Margin="-1" Opacity="0.8">
            <Rectangle.Effect>
                <BlurEffect Radius="15" />
            </Rectangle.Effect>
        </Rectangle>
        <Rectangle Fill="White"/>
        <ProgressBar Name="LoadingProgressBar" Style="{StaticResource MetroProgressBarStyle}" Foreground="{StaticResource AccentColor}" IsIndeterminate="{Binding IsLoading}" Visibility="{Binding IsLoading, Converter={StaticResource VisibilityConverter}, ConverterParameter=Visible}" VerticalAlignment="Top" Padding="0"/>
        <Rectangle Height="2" Fill="{StaticResource AccentColor}" VerticalAlignment="Top"/>
        <Rectangle Width="50" Height="16" Fill="{StaticResource AccentColor}" VerticalAlignment="Top" HorizontalAlignment="Left" Margin="9,0,0,0"/>
        <Grid VerticalAlignment="Top" HorizontalAlignment="Right">
            <StackPanel Grid.Column="2" Orientation="Horizontal" VerticalAlignment="Top" HorizontalAlignment="Right" Margin="10">
                <Button Style="{StaticResource MiniModeButtonStyle}" Click="MiniModeButtonClick"/>
                <Button Style="{StaticResource MinimizeButtonStyle}" Margin="5,0,5,0" Click="MinimizeButtonClick"/>
                <Button Style="{StaticResource CloseButtonStyle}" Click="CloseButtonClick"/>
            </StackPanel>
        </Grid>
        <ListBox Name="AudioList" Grid.Row="2" ItemTemplate="{StaticResource MyAudioMiniItemTemplate}" ItemContainerStyle="{StaticResource MetroListboxItemStyle}" HorizontalContentAlignment="Stretch" 
                 ItemsSource="{Binding MyAudio}" Margin="0,30,0,35" BorderThickness="0" SelectedIndex="{Binding MyAudioSelectedIndex}"
                 ScrollViewer.ScrollChanged="MyAudioListScrollChanged"/>
        <StackPanel Orientation="Horizontal" VerticalAlignment="Bottom" HorizontalAlignment="Center" Margin="0,0,0,5">
            <ToggleButton Name="ShuffleButton" Grid.Column="0" Template="{StaticResource Shuffle}" Width="14" IsEnabled="{Binding IsLoaded}" Margin="0,0,5,0" IsChecked="{Binding Shuffle}"/>
            <Button Name="PrevButton" Grid.Column="1" Template="{StaticResource Prev}" Width="20" IsEnabled="{Binding IsLoaded}" Click="PrevButtonClick">
                <Button.RenderTransform>
                    <TranslateTransform />
                </Button.RenderTransform>
            </Button>
            <ToggleButton Name="PlayPauseButton" Grid.Column="2" Template="{StaticResource PlayPause}" Margin="3,0,3,0" Width="28" IsEnabled="{Binding IsLoaded}" IsChecked="{Binding IsPlaying, Mode=OneWay}" Click="PlayPauseButtonClick">
                <ToggleButton.RenderTransform>
                    <TranslateTransform />
                </ToggleButton.RenderTransform>
            </ToggleButton>
            <Button Name="NextButton" Grid.Column="3" Template="{StaticResource Next}" Width="20" IsEnabled="{Binding IsLoaded}" Click="NextButtonClick">
                <Button.RenderTransform>
                    <TranslateTransform />
                </Button.RenderTransform>
            </Button>
            <ToggleButton Name="LikeButton" Margin="5,0,0,0" Template="{StaticResource Favourite}" Width="14" Cursor="Hand" IsEnabled="{Binding CanLike}" Click="LikeButtonClick" IsChecked="{Binding CurrentAudio.IsAddedByUser, Mode=OneWay}"/>
        </StackPanel>
    </Grid>
</Window>
